package br.com.condominio.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import br.com.condominio.dao.BlocoDAO;
import br.com.condominio.entity.Bloco;

@Service("blocoService")
public class BlocoService {

	@Autowired
	private BlocoDAO dao;

	public List<Bloco> getAllBlocos() {
		return dao.findAll();
	}

	public List<Bloco> getBlocosByName(String string) {
		return dao.findByName(string);
	}

	public Bloco persistBloco(Bloco bloco) {
		return dao.persist(bloco);
	}

	public void updateBloco(Bloco bloco) {
		dao.merge(bloco);
	}

	public void deleteBloco(Bloco bloco) {
		dao.delete(bloco);
	}

	public void setDao(BlocoDAO dao) {
		this.dao = dao;
	}

	public Bloco getBlocosById(Integer id) {
		return dao.findById(id);
	}

}
